<template>
	<van-grid :column-num="4">
		<van-grid-item v-for="item,index in menuinfos.data" :key="index" :text="item.title">
			<template #icon>
				<van-image  width="50" height="50" round
				   :src="item.image"
				/>
			</template>
		</van-grid-item>
	</van-grid>
</template>

<script setup>
	import {
		reactive,
		onMounted
	} from "vue"
	import {
		getHomeMenu
	} from "@/api/common"
	var menuinfos = reactive({
		data: [],
	});

	onMounted(() => {
		getData()
	})

	const getData = () => {
		getHomeMenu()
			.then(res => {
				console.log('getHomeMenu', res)
				if (res.code != 0) {
					console.log(`获取数据失败，` + res.message);
				} else {
					menuinfos.data = res.data
					console.log("获取数据成功")
				}
			})
			.catch(err => {
				console.log(err, `服务端错误！`)
			})
	};
</script>

<style>
</style>
